<?php

// Prevent individual file access
if(!defined('DIR_BASE')) exit;

/**
 * Filter on specific things
 */
class Filter {
	
	/**
	 * Validate the string with a given character set
	 * @param String $string The string to validate
	 * @return Boolean success
	 */
	public static function str($string){
		// TODO : good validation
		return true;
	}
	
	/**
	 * Check if it is a valid word
	 * @param String $word The word where it is about
	 * @param Array $notAllowed (optional) Contains an array with words/text that are not allowed
	 * @return Boolean success
	 */
	public static function word($word, $notAllowed = array()) {
		// filter not allowed words and words must have a minumum of 2 characters
		if (strlen($word) <= 2 ||
			in_array($word, $notAllowed)){
				return false;
		}
		// check if it contains only letters
		$filtered = (string) preg_replace( '/[^A-Z_]/i', '', $word );
		return ($filtered == $word);
	}
	
	/**
	 * Check for correct filetype
	 * @param String $filename The filename with extention
	 * @return Boolean success
	 */
	public static function fileType($filename) {
		return (pathinfo($filename, PATHINFO_EXTENSION) == 'png');
	}
}
?>
